//#include <gtk/gtk.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <fstream>
#include <cstdio>
#include <string>
#include <istream>
#include "vector.hpp"
#include "dbutil.hpp"
#include "stringutil.hpp"
#define hexNumber(a) setfill('0')<<setw((sizeof((a)))/4)<<hex<<a
#define catchERR(a) catch(a& err){ "catch"#a(err); }

using namespace std;
void waitForEnter(string msg,char check = '\0',ostream& out = cout,istream& in = cin){
	out<<endl<<msg;
	char c;
	if(check) while( ( c = in.peek() ) != check ) in.ignore(1);
	else while( ( c = in.peek() ) != '\n') in.ignore(1);
}
class command{
	private:
	
	public:
		command(char* val,SQL& db){
			/* ------------------------------------------------------------------ */
			/* VAL is a single command. It should have the command name,        - */
			/* followed by an open parenthesis. Then a comma separated list     - */
			/* of arguments, then ended with a closing parenthesis and semicolon- */
			/* ------------------------------------------------------------------ */
			char* nString = new char[strlen(val)+1];
			strncpy(nString,val,strlen(val)+1);
			//There should be no spaces, new lines, or tabs.
			char* command = nString;
			char* argumentsStart = command;
			delete nString;
		}
		~command(){
		
		}
}
int main(int argc,char** argv){
	//har dir[FILENAME_MAX];
	//GetCurrentDir(dir,FILENAME_MAX);
	for(int i = 0;argv[i];i++)cout<<argv[i]<<endl;
	try{
		//cout<<dir<<dirSep<<"gearedsun.sql"<<endl;
		SQL database("gearedSun.sql");
		ifstream sf("script.gss",ios::ate);
		char* str = getString(sf);
		sf.close();
			if(str){
			str = removeAll(str," \n\t");
			str = replaceChars(str,";\n");
			str = removeDuplicates(str,";\n");
			char** index = splitString(str,'\n');
			for(int i =0;index[i];i++){
        command CMD(index[i],database);
				//string q = "SELECT * FROM PKMN WHERE NAME LIKE \"" + string(index[i]) + "\"";
				//database.Query(q,outlineRow);
			}
			delete[] str;
			delete index;
		}
	}
	catch(sqlErr& err){
		err.out();
	}
	waitForEnter("Push any key to continue");
	return 0;
}
